home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / asmsrc / tango2.lha / SOURCES / 2PIX.s < prev    next >
Encoding:
Text File  |  1988-07-19  |  11.4 KB  |  554 lines

  1. ;    ** RAY SEE IF KODAK CAN MAKE THIS ANY BETTER **
  2. ; ** 2 PIXEL ACCURACY SINE WAVE BY TANGO OF CRYPTIC **
  3. ;     ** ONLY SPREAD SOURCE TO CRYPTIC MEMBERS **
  4.  
  5.     opt c-
  6.     section blitter,code_c            Chip Ram please !!
  7.     include    df1:definitions            Give me some hardware reggies
  8.     include    df1:macros                Give me some macros
  9.     
  10.         
  11. ;LOCAL CONSTANTS
  12.  
  13. icra        equ $bfed01                
  14. allocmem     =-30-168                
  15. freemem     =-30-180                
  16.  
  17. TAKEOVER:
  18.  
  19. ; KILL SYSTEM COPPER, KEYBOARD ETC.....
  20.  
  21.     LEA custom,a5        
  22.     LEA GFXLIB(PC),a1             Point to 'graphics.library'
  23.     MOVEQ #0,D0                     Doesn't matter which version
  24.      MOVE.L 4.w,a6                 EXECBASE
  25.     jsr    -132(a6)                 task switching off (forbid)
  26.      JSR -$228(a6)                  Openlibrary
  27.      MOVE.L D0,GFXBASE             Store library address
  28.  
  29.         
  30. ;Now put the graphic addresses in the CopperList         
  31.  
  32.  
  33.      move.l    #sprite,d1            
  34.      move.w    d1,sp0lo+2
  35.      swap    d1
  36.      move.w    d1,sp0hi+2
  37.  
  38.  
  39.      move.l GFXBASE,d0            Move gfxbase offset to d0
  40.      MOVE.L D0,A6                
  41.      MOVE.W #$80,dmacon(a5)        Turn off copper whilst changing it
  42.      MOVE.L $32(A6),WBCOPPER         Store old (WBench) copper address
  43.      MOVE.L #OURCOPPER,$32(A6)    Point to new copper list (our own)
  44.      MOVE.W #$8080,dmacon(a5)    re-enable copper
  45.  
  46.      MOVE.W #$8010,intena(a5)        
  47.      MOVE.L $6c,old                Save work bench interrupt
  48.      MOVE.L #LEV3,$6c            This sets up a level 3 interrupt
  49.     move.w    intenar(a5),systemints
  50.     move.b    #%01111111,icra        Kill keyboard
  51.         
  52. WAIT:     
  53.     BTST #6,$BFE001                This waits for the left
  54.      BNE.S    WAIT                mouse button to be pressed
  55.     move.l    4.w,a6                EXECBASE
  56.      MOVE.L old,$6c                Restore system interrupts
  57.     MOVE.L GFXBASE,A6
  58.      MOVE.W #$80,dmacon(a5)        Disable DMA
  59.      MOVE.L WBCOPPER,$32(A6)        Restore old copperlist
  60.      MOVE.W #$8080,dmacon(a5)    Enable DMA
  61.      move.w    systemints,d0        Systems interrupt
  62.      or.w    #$c000,d0
  63.      move.w    d0,intena(a5)        Enable OS interrupts
  64.      move.b    #%10011011,icra        Enable keyboard
  65.     clr.w    $dff0a8                Clear music
  66.     clr.w    $dff0b8
  67.     clr.w    $dff0c8
  68.     clr.w    $dff0d8
  69.     move.w    #$f,$dff096
  70.     CLR.L    D0
  71.     rts
  72.  
  73.  
  74. ERROR:    
  75.     move.l 4.w,a6                Get EXECBASE
  76.     jsr    -138(a6)                Permit ( multi-tasking on )
  77.     moveq    #0,d0                Clear d0
  78.      RTS                            Return to AmigaDOS
  79.  
  80.  
  81. ;This is the NEW level 3 interrupt
  82.  
  83. LEV3:
  84.      MOVEM.L d0-d7/a0-a6,-(sp)    Save all registers to the stack
  85.     lea    custom,a5
  86.     AND #$10,intreqr(a5)           Check if interrupt is from Copper 
  87.     BNE out
  88.     move.w    #$8010,$9c                                
  89.     
  90.  
  91. ; ** ALL ROUTINES CALLED (HOPEFULLY) EVERY VBI **
  92.  
  93.     bsr    try_sin
  94.     bsr    testscroll
  95.  
  96.      move.l    sin_screen,d1        Bitplane memory address
  97.     move.w    d1,bp1lo+2            Used for double buffering
  98.      swap    d1
  99.      move.w    d1,bp1hi+2
  100.  
  101.     bsr        move_stars
  102.  
  103.     
  104. out:     
  105.     MOVEM.L (sp)+,d0-d7/a0-a6    Restore the registers
  106.     DC.W $4ef9                    hex value for  JMP instruction
  107. old:     
  108.     DC.L 0                        will jump to normal interrupt
  109.  
  110.  
  111. ; ** Move the sprites **
  112.  
  113. move_stars:
  114.  
  115.     sub.b    #$1,x+1
  116.     sub.b    #$2,x+9
  117.     sub.b    #$1,x+17
  118.     sub.b    #$3,x+25
  119.     sub.b    #$2,x+33
  120.     sub.b    #$4,x+41
  121.     sub.b    #$2,x+49
  122.     sub.b    #$1,x+57
  123.     sub.b    #$3,x+65
  124.     sub.b    #$1,x+73
  125.     sub.b    #$2,x+81
  126.     sub.b    #$4,x+89
  127.     sub.b    #$3,x+97
  128.     sub.b    #$2,x+105
  129.     sub.b    #$1,x+113
  130.     sub.b    #$4,x+121
  131.     sub.b    #$3,x+129
  132.     sub.b    #$3,x+137
  133.     sub.b    #$2,x+145
  134.     sub.b    #$4,x+153
  135.     sub.b    #$1,x+161
  136.     sub.b    #$3,x+169
  137.     sub.b    #$1,x+177
  138.     sub.b    #$2,x+185
  139.     sub.b    #$4,x+193
  140.     sub.b    #$1,x+201
  141.     sub.b    #$3,x+209
  142.     sub.b    #$1,x+217
  143.     sub.b    #$2,x+225
  144.     sub.b    #$2,x+233
  145.     rts
  146.  
  147.  
  148. ; ** Double Buffer The Screen **
  149.  
  150. Buff:
  151.     Eor.l    #10240,Tango                ; Next screen is 10240 bytes along
  152.     Move.l    Tango,D1
  153.     Move.l    #SinePlane,d2
  154.     Add.l    D1,d2
  155.     Move.l    D2,Sin_Screen
  156.     Rts
  157.  
  158.  
  159. ; ** THE SCROLL ROUTINE **
  160.  
  161. testscroll:
  162.     tst.l    stopper
  163.     beq.s    scroll
  164.     sub.l    #1,stopper
  165.     rts
  166. scroll:
  167.     cmp.l    #15*4,val                Blitshifted all <<<
  168.     blo.s    coarse_scroll_it        No then get doing it !!
  169.     bsr        blit_char                Blit letter to screen
  170.     clr.l    val                        Reset index
  171. coarse_scroll_it:
  172.     bsr        coarse                    Scroll all line
  173.     rts                            
  174.     
  175.     
  176. ; ** BLIT LETTER ON THE SCREEN **
  177.  
  178. blit_char
  179.     jsr        text
  180.     lea        custom,a5                Get custom chip address
  181.     move.l    screenx,a0                 Can~t see this picture !!
  182.     move.l    #font,a1                 Put font in blitter source
  183.     add.l    d1,a1
  184. blit_test:
  185.     btst    #14,$dff002                 Blitter busy !!!
  186.     bne    blit_test                     Lets wait till she finishes !
  187.     move.w    #$ffff,bltafwm(a5)        
  188.     move.w    #$ffff,bltalwm(a5)        
  189.     move.l    a0,bltdpth(a5)             Blitter dest D (BOTTOM OF SCREEN)
  190.     move.l    a1,bltapth(a5)             Blitter source A (SCROLLING FONT)
  191.     move.w    #38,bltamod(a5)             Modulo (20-1)*2
  192.     move.w    #38,bltdmod(a5)             Modulo (20-1)*2
  193.     move.w    #$9f0,bltcon0(a5)         Minterms D=A
  194.     clr.w    bltcon1(a5)                 Set Ascending mode
  195.      move.w    #16*64+1,bltsize(a5)     Blit size (SIZE OF FONT)
  196.     rts                                  Return
  197.  
  198.  
  199. ; ** BLITSHIFT THE ENTIRE SCROLL LINE **
  200.  
  201. coarse:
  202.     lea        custom,a5                 
  203.     move.l    screenx,a0                ; Can~t see this picture !!
  204.     move.l    a0,a1
  205.     add.l    #2,a1
  206. blit_wait:
  207.     btst    #14,$dff002            
  208.     bne        blit_wait
  209.     incl    #4,val                    ; (1 for slower)
  210.     move    #15,d7                    ; Amount of pixels to shift(15 for slow)
  211.     ror        #4,d7                    ; Set to correct bits (12-15)
  212.     or        #%100111110000,d7        
  213.     move.l    #-1,bltafwm(a5)
  214.     move.l    a1,bltapth(a5)
  215.     move.l    a0,bltdpth(a5)
  216.     move.w    #0,bltamod(a5)
  217.     move.w    #0,bltdmod(a5)
  218.     move.w    d7,bltcon0(a5)    
  219.     move.w    #80*64+20,bltsize(a5)
  220.     rts    
  221.  
  222.  
  223. ; ** BLITTER CLEAR WHERE THE SINE SCROLL HAS JUST BEEN **
  224.  
  225. CLEAR:
  226.     Move.l    Sin_Screen,a0
  227. wate
  228.     btst    #14,$dff002
  229.     bne.s    wate
  230.     Move.l    a0,Bltdpth(a5)
  231.     Move    #0,Bltdmod(a5)
  232.     Move.l    #$1f00000,Bltcon0(a5)
  233.     Move    #150*64+20,Bltsize(a5)
  234.     Rts
  235.  
  236.  
  237. ; ** DO THE SINEWAVE **
  238. ; BLITTER HAS TO COPY EVERY 2 PIXELS ACROSS, THATS ALOT OF WORK !!!
  239.  
  240. try_sin:
  241.     Bsr        buff
  242.     bsr        clear
  243.     Move.l    Table1,A3
  244.     Move.b    (A3),d1
  245.     Cmp.b    #$ff,d1
  246.     Bne        ItsOkYa
  247.     Move.l    #SinTab,A3
  248. ItsOkYa
  249.     Add.l    hi_amplitude,A3
  250.     Move.l    a3,Table1
  251.     Move.l    A3,Table
  252.     lea        custom,a5                 
  253.     move.l    screenx,a0                 ; Source A
  254.     move.l    #20,d4                    ; Number of chars along screen
  255.     clr.l    d5
  256.     clr.l    d6
  257. ban:
  258.     move.w    #%1100000000000000,d3    ; PUT TO 1 FOR ONE PIXEL 
  259.     move.l    #7,d2                    ; PUT TO 15 FOR ONE PIXEL
  260. blit_test0:
  261.     btst    #14,$dff002                 
  262.     bne    blit_test0                     
  263.     move.l    sin_screen,a1
  264.     bsr        get_sinvalue
  265.     move.w    d3,bltafwm(a5)        
  266.     move.w    d3,bltalwm(a5)        
  267.     move.l    a1,bltdpth(a5)             
  268.     move.l    a1,bltbpth(a5)             
  269.     move.l    a0,bltapth(a5)             
  270.     move.w    #38,bltamod(a5)             
  271.     move.w    #38,bltdmod(a5)             
  272.     move.w    #38,bltbmod(a5)             
  273.     move.w    #$dfc,bltcon0(a5)         
  274.     clr.w    bltcon1(a5)                 
  275.      move.w    #16*64+1,bltsize(a5)     
  276.     lsr.w    #2,d3                    ; PUT TO LSR.W #1 FOR 1 PIXEL
  277.     dbf        d2,blit_test0            ; GET NEXT PIXEL ACROSS
  278.     add.l    #2,a0                    ; Get next letter along
  279.     add.l    #2,d6
  280.     dbf        d4,ban
  281.     rts                                  
  282.  
  283. get_sinvalue:
  284.     Clr.l    D5
  285.     Move.l    Table,A3
  286.     Move.b    (A3),d5
  287.     cmp.b    #$ff,d5
  288.     bne        cryptic90
  289.     Move.l    #SinTab,A3
  290.     Move.b    (a3),d5
  291. cryptic90
  292.     Add.l    lo_amplitude,A3
  293.     Move.l    A3,Table
  294.     mulu    #40,d5
  295.     add.l    d5,a1
  296.     Add.l    D6,A1
  297.     rts
  298. Table1:    Dc.l    SinTab    
  299. table:    dc.l    sintab
  300.  
  301.  
  302. ; ** RAY SEE IF YOU CAN GET A BETTER SINUS TABLE FOR FULL SCREEN !!! **
  303. sintab:
  304.     dc.b $3C,$3F,$42,$46,$49,$4C,$50,$53,$56,$59
  305.     dc.b $5C,$5F,$61,$64,$67,$69,$6B,$6D,$6F,$71
  306.     dc.b $72,$73,$75,$76,$76,$77,$77,$77,$77,$77
  307.     dc.b $77,$76,$76,$75,$73,$72,$71,$6F,$6D,$6B
  308.     dc.b $69,$67,$64,$61,$5F,$5C,$59,$56,$53,$50
  309.     dc.b $4C,$49,$46,$42,$3F,$3C,$38,$35,$31,$2E
  310.     dc.b $2B,$27,$24,$21,$1E,$1B,$18,$16,$13,$10
  311.     dc.b $E,$C,$A,$8,$6,$5,$4,$2,$1,$1
  312.     dc.b $0,$0,$0,$0,$0,$0,$1,$1,$2,$4
  313.     dc.b $5,$6,$8,$A,$C,$E,$10,$13,$16,$18
  314.     dc.b $1B,$1E,$21,$24,$27,$2B,$2E,$31,$35
  315.     dc.b $38,255
  316.      EVEN
  317.      
  318.  
  319. ; ** CHARACTER DECODER ROUTINE **
  320.  
  321. text:
  322.     move.l    acurent,a2                Get message
  323.     clr.l    d1                        
  324.     move.b    (a2)+,d1                Update it
  325.     move.b    d1,letter                Store in offset
  326.     cmp.b    #255,d1                    Check for end of message
  327.     beq.w    rst_text                If equal, then reset
  328.     cmp.b    #254,d1
  329.     beq        stop
  330.     sub.l    #32,d1                    Subract 32 (ie space)
  331.     asl        d1                        Times by 2 
  332.     move.l    a2,acurent                Update acurent
  333.     CMP.B    #"4",letter                Is letter "K" or larger
  334.     BPL.s    add_more                If larger then add on
  335.     rts                                Return
  336. add_more:
  337.     CMP.B    #"H",letter                Is letter "U" or larger
  338.     BPL.S    add_more2                If larger then add on
  339.     add.l    #40*15,d1                Get next line down (KLMNOPQRST)
  340.     rts
  341. add_more2:                    
  342.     add.l    #40*30,d1                Get next line down (UVWXYZ0123)
  343.     rts
  344. rst_text:
  345.     move.l    #0,d1
  346.     move.l    #message,d2                Get begining of text
  347.     move.l    d2,acurent                Reset to begining
  348.     rts                                Return
  349. stop:
  350.     move.l    #0,d1
  351.     add.l    #1,acurent
  352.     move.l    #150,stopper
  353.     rts
  354.  
  355. message:
  356.  
  357. ; 254=STOP,255=END.
  358.  
  359.     DC.B    " HI RAY    THIS IS A 2 PIXEL SINE SCROLL (HONESTLY!!)"
  360.     DC.B    "  CHECK OUT THE SINETABLE IN THE SOURCE AND SEE IF YOU CAN GET A BETTER AND BIGGER ONE TO GET FULL SCREEN"
  361.     DC.B    "  ALSO SEE IF KODAK CAN MAKE THIS RUN ANY FASTER COS ITS ABIT SLOOOOW"
  362.     DC.B    "  WRITE SOON....      PS. I'LL SEE YA ALL IN BLACKPOOL ON SATURDAY !!!!!"
  363.     DC.B    "   WRAP           ",255
  364.     EVEN
  365.             
  366.  
  367. ; ** THE COPPERLIST **
  368.  
  369. OURCOPPER:
  370. sp0lo:    dc.w    spr0ptl,$0000
  371. sp0hi:    dc.w    spr0pth,$0000
  372.         dc.w    bpl1mod,0,bpl2mod,0
  373.         dc.w    diwstrt,$2c81+16,diwstop,$2cc1
  374.         dc.w    bplcon0,$1200,bplcon1,$0000
  375.         dc.w    ddfstrt,$38,ddfstop,$d0
  376.         dc.w    color00,$000,color01,$094
  377.         dc.w    color16,$aaa,color17,$aaa,color18,$aaa
  378.         dc.w    color19,$aaa,color20,$aaa
  379. bp1lo:    dc.w    bpl1ptl,$0000
  380. bp1hi:    dc.w    bpl1pth,$0000
  381.         wait    $2c09,$fffe
  382.         dc.w    color01,$f00
  383.         wait    $2e09,$fffe
  384.         dc.w    color01,$f11
  385.         wait    $3009,$fffe
  386.         dc.w    color01,$f00
  387.         wait    $3209,$fffe
  388.         dc.w    color01,$f11
  389.         wait    $3409,$fffe
  390.         dc.w    color01,$f22
  391.         wait    $3609,$fffe
  392.         dc.w    color01,$f33
  393.         wait    $389,$fffe
  394.         dc.w    color01,$f44
  395.         wait    $3a09,$fffe
  396.         dc.w    color01,$f55
  397.         wait    $3c09,$fffe
  398.         dc.w    color01,$f66
  399.         wait    $3e09,$fffe
  400.         dc.w    color01,$f77
  401.         wait    $4009,$fffe
  402.         dc.w    color01,$f88
  403.         wait    $4209,$fffe
  404.         dc.w    color01,$f99
  405.         wait    $4409,$fffe
  406.         dc.w    color01,$faa
  407.         wait    $4609,$fffe
  408.         dc.w    color01,$fbb
  409.         wait    $4809,$fffe
  410.         dc.w    color01,$fcc
  411.         wait    $4a09,$fffe
  412.         dc.w    color01,$fdd
  413.         wait    $4c09,$fffe
  414.         dc.w    color01,$fee
  415.         wait    $4e09,$fffe
  416.         dc.w    color01,$fff
  417.         wait    $5109,$fffe
  418.         dc.w    color01,$eef
  419.         wait    $5309,$fffe
  420.         dc.w    color01,$ddf
  421.         wait    $5509,$fffe
  422.         dc.w    color01,$ccf
  423.         wait    $5709,$fffe
  424.         dc.w    color01,$bbf
  425.         wait    $5909,$fffe
  426.         dc.w    color01,$aaf
  427.         wait    $5b09,$fffe
  428.         dc.w    color01,$99f
  429.         wait    $5d09,$fffe
  430.         dc.w    color01,$88f
  431.         wait    $5f09,$fffe
  432.         dc.w    color01,$77f
  433.         wait    $6109,$fffe
  434.         dc.w    color01,$66f
  435.         wait    $6309,$fffe
  436.         dc.w    color01,$55f
  437.         wait    $6509,$fffe
  438.         dc.w    color01,$44f
  439.         wait    $6709,$fffe
  440.         dc.w    color01,$33f
  441.         wait    $6909,$fffe
  442.         dc.w    color01,$22f
  443.         wait    $6a09,$fffe
  444.         dc.w    color01,$11f
  445.         wait    $6c09,$fffe
  446.         dc.w    color01,$00f
  447.         wait    $6e09,$fffe
  448.         dc.w    color01,$11f
  449.         wait    $7109,$fffe
  450.         dc.w    color01,$22f
  451.         wait    $7309,$fffe
  452.         dc.w    color01,$33f
  453.         wait    $7509,$fffe
  454.         dc.w    color01,$44f
  455.         wait    $7709,$fffe
  456.         dc.w    color01,$55f
  457.         wait    $7909,$fffe
  458.         dc.w    color01,$66f
  459.         wait    $7a09,$fffe
  460.         dc.w    color01,$77f
  461.         wait    $7c09,$fffe
  462.         dc.w    color01,$88f
  463.         wait    $7e09,$fffe
  464.         dc.w    color01,$99f
  465.         wait    $8009,$fffe
  466.         dc.w    color01,$aaf
  467.         wait    $8209,$fffe
  468.         dc.w    color01,$bbf
  469.         wait    $8409,$fffe
  470.         dc.w    color01,$ccf
  471.         wait    $8609,$fffe
  472.         dc.w    color01,$ddf
  473.         wait    $8809,$fffe
  474.         dc.w    color01,$eef
  475.         wait    $8a09,$fffe
  476.         dc.w    color01,$fff
  477.         wait    $8c09,$fffe
  478.         dc.w    color01,$fee
  479.         wait    $8e09,$fffe
  480.         dc.w    color01,$fdd
  481.         wait    $9109,$fffe
  482.         dc.w    color01,$fcc
  483.         wait    $9309,$fffe
  484.         dc.w    color01,$fbb
  485.         wait    $9509,$fffe
  486.         dc.w    color01,$faa
  487.         wait    $9709,$fffe
  488.         wait    $9909,$fffe
  489.         dc.w    color01,$f99
  490.         wait    $9b09,$fffe
  491.         dc.w    color01,$f88
  492.         wait    $9d09,$fffe
  493.         dc.w    color01,$f77
  494.         wait    $9f09,$fffe
  495.         dc.w    color01,$f66
  496.         end_copper
  497.         
  498.  
  499. ;LOCAL CONSTANTS
  500.  
  501. WBCOPPER:        DC.L    0
  502. GFXLIB:            DC.B     "graphics.library",0
  503. GFXBASE:        DC.L    0
  504. systemints:        dc.l    0
  505. scroll_offset:    dc.l    0
  506. screenx:        dc.l    picture
  507. letter:            dc.b    0
  508. acurent:        dc.l    message
  509. val:            dc.l    0
  510. lo_amplitude:    dc.l    1                        ; PISS AROUND WITH THESE
  511. hi_amplitude:    dc.l    2                        ; PISS AROUND WITH THESE
  512. Tango            Dc.l    0
  513. sin_screen:        Dc.l    SinePlane
  514. stopper:        dc.l    0
  515.  
  516.  
  517. ;BINARY FILES TO BE INCLUDED
  518.     EVEN
  519. picture    
  520.     dcb.b    10240,0
  521. SinePlane
  522.     dcb.b    10240,0
  523.     dcb.b    10240,0
  524. font
  525.     incbin    df1:neatfont.bin
  526. sprite:
  527.     include    df1:sprite.list
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.     
  535.     
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.     
  544.     
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.